package configuration

import (
	"encoding/json"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

var GuildSkillConfigs []GuildSkillConf

type GuildSkillConf struct {
	ID        int32   // 索引ID
	SkillID   int32   // 技能ID
	Level     int32   // 等级
	Name      string  // 技能名称
	GradeMax  int32   // 最大等级
	ShipID    int32   // 船只ID
	Camp      int32   // 阵营
	Rate      float32 // 加成数值
	CostCount int32   // 消耗数量
}

func init() {

	var err error
	if err = json.Unmarshal(client.Load("SkillGuild"), &GuildSkillConfigs); err != nil {
		panic(err)
	}

	log.Info("Load SkillGuild.json success.")
}

func GetSkill(skillID, lv int32) GuildSkillConf {

	for _, v := range GuildSkillConfigs {
		if v.SkillID == skillID && v.Level == lv {
			return v
		}
	}

	panic(fmt.Errorf("GuildSkillConf not found [%d]", skillID))
}
